#include "syscall.h"

/*
Test MV Function
Output will be
10
9
8
7
6
5
4
3
2
1
*/

int mv;

char buf[200];
int len = 0;

void print(int x) {
	int num = 1;
	int t = x/10;
	int i;
	char a[11];
	while (t) {
		num++;
		t /= 10;
	}
	for(i = 1; i <= num; i++) {
		a[num-i] = (x%10) + '0';
		x /= 10;
	}
	for(i = 0; i < num; i++) {
		buf[len++] = a[i];
	}
/*	Write(a, num, ConsoleOutput); */
}

void prints(char *a) {
	int i;
	for(i = 0; a[i]; i++)
		buf[len++] = a[i];
	if (buf[len-1] == '\n') {
		Write(buf,len,ConsoleOutput);
		len = 0;
	}
}

int main() {
	int i;
	mv = CreateMonitor("a", 1, 10);
	prints("MV Created "); print(mv); prints("\n");

	for(i = 0; i < 10; i++) SetMonitor(mv, i, 10-i);
	for(i = 0; i < 10; i++) {
		print(ReadMonitor(mv,i));prints("\n");
	}
	DestroyMonitor(mv);
	Exit(0);
}
